package com.test.springboot_test.stringTest;

import java.util.Arrays;

public class SpringTest9 {
    public static void main(String[] args) {
        /**
         * 字符的基本操作
         * 1.字符串截取
         * 2.字符串拼接
         * 3.字符串索引，匹配从前往后
         * 4.字符串索引，匹配从后往前
         * 5.字母从大到小，字符串切换
         * 6.字母从小到大，字符串切换
         * 7.字符串分割成数组
         */

        //截取、索引
        String a = "1+1=@2";
        System.out.println(a.substring(0, a.lastIndexOf("@")));
        System.out.println(a.substring(a.lastIndexOf("@")+1));

        //拼接
        String [] str = {"1","2","3","4"};
        StringBuilder builder = new StringBuilder();
        for(String a1 : str){
            builder.append(a1);
        }
        System.out.println(builder.toString());

        //字符分割成数组
        String str2 = "1,2,3,4,5,6,7,8,9,10";
        String [] str3 = str2.split(",");
        System.out.println(Arrays.asList(str3).toString());


    }

}
